<template>
  <el-dialog title="查看计费方式" :visible.sync="visible" :close-on-click-modal="false">
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="计费方式" name="first">
        <el-table
          :data="feeModel.groupCarChargeRuleDtoList"
          border
          style="width: 100%">
          <el-table-column
            label="时段"
            width="200">
            <template slot-scope="scope">
              {{scope.row.startTime}} 至 {{scope.row.endTime}}
            </template>
          </el-table-column>
          <el-table-column
            prop="chargePrice"
            label="电价(元/度)">
          </el-table-column>
          <el-table-column
            prop="serviceAmount"
            label="服务费(元/度)">
          </el-table-column>
          <el-table-column
            prop="totalPrice"
            label="总价(元/度)">
          </el-table-column>
          <el-table-column
            label="当前时段">
            <template slot-scope="scope">
              <i v-if="scope.row.currentTimeRang" class="el-icon-check"></i>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="收费方式" name="second">
        <div class="second-pan">
          <avue-crud ref="crud"
                     :data="feeModel.carGroupBillingPlanMappingList"
                     :option="tableOption1"></avue-crud>
        </div>
      </el-tab-pane>
      <el-tab-pane label="站点标签" name="third">
        <div class="third-pan">
          <el-tag
            :key="tag.id"
            v-for="tag in feeModel.chargingGroupLabelVoList"
            :disable-transitions="false">
            {{tag.name}}
          </el-tag>
        </div>
      </el-tab-pane>
    </el-tabs>
    <div class="footer">
      <el-button @click.stop="visible=false">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "fee-car-dialog",
  data(){
    return{
      id:'',
      vipTotal:0,
      visible:false,
      activeName:'first',
      feeModel:{
        activityChargeVo:{},
        vipChargingVo:{},
        isCardEnable:0
      },
      dataList:[],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      tableOption1:{
        border: true,
        index: true,
        indexLabel: '序号',
        stripe: false,
        menuAlign: 'center',
        align: 'center',
        refreshBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        header: false,
        menu: false,
        page:false,
        props: {
          label: 'label',
          value: 'value'
        },
        column: [{
          label: '收费方式',
          prop: 'billingType',
          type:'select',
          dicData:[{
            label:'智能充电',
            value:0
          },{
            label:'金额收费',
            value:1
          },{
            label:'自定义收费',
            value:2
          }]
        },{
          label: '计费值',
          prop: 'billingValue',
        }]
      },
      tableOption:{
        border: true,
        index: true,
        indexLabel: '序号',
        stripe: false,
        menuAlign: 'center',
        align: 'center',
        refreshBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        header: false,
        menu: false,
        props: {
          label: 'label',
          value: 'value'
        },
        column: [{
          label: '姓名',
          prop: 'name',
        },{
          label: '手机号',
          prop: 'mobile',
        },{
          label: '总次数',
          prop: 'totalCount',
        },{
          label: '使用次数',
          prop: 'useCount',
        },{
          label: '到期时间',
          prop: 'endTime',
        }]
      }
    }
  },
  methods:{
    init(id){
      this.visible=true
      this.id=id
      this.getFee(id)
    },
    getFee(id){
      this.$http({
        url:this.$http.adornUrl('/v1/merchant/charging/group/get/billing/car'),
        method:'get',
        params:this.$http.adornParams({id:id})
      }).then(({data})=>{
        this.feeModel=data.data
      })
    },
    currentChange(val){
      this.page.currentPage=val
      this.getDataList(this.page)
    },
    sizeChange(val){
      this.page.pageSize=val
      this.getDataList(this.page)
    }
  }
}
</script>

<style lang="scss" scoped>
.first-pan{
  margin-bottom:20px;
  span:nth-child(1),span:nth-child(3){
    display: inline-block;
    width: 60px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background-color: #E8E8E8;
  }
  span:nth-child(2){
    display: inline-block;
    margin-left: 5px;
    margin-right: 5px;
  }
  span:nth-child(4){
    display: inline-block;
    margin-left: 5px;
  }
  span:nth-child(5){
    display: inline-block;
    margin-left: 50px;
  }
}
.second-pan{
  div{
    margin-top: 10px;
    font-size: 14px;
    color: #333333;
  }
}
.section{
  margin-top: 20px;
  .total{
    display: inline-block;
    margin-left: 50px;
    color: #333333;
    font-weight: normal;
    font-size: 14px;
  }
}
.section-tlt{
  color: #333333;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}
.third-pan{
  .item{
    padding-left: 20px;
    margin-top: 8px;
    &>span:nth-child(2){
      display: inline-block;
      width: 60px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      background-color: #E8E8E8;
      margin: 0px 20px;
    }
  }
}
.footer{
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
}
.empty{
  text-align: center;
  margin-top: 20px;
  font-size: 16px;
}
.el-tag + .el-tag {
    margin-left: 10px;
  }
</style>
